import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: const Center(
          child: Text(
            "appbar",
            textDirection: TextDirection.ltr,
            style: TextStyle(
                fontSize: 10, color: Colors.green, fontWeight: FontWeight.bold),
          ),
        ),
        backgroundColor: Colors.deepPurpleAccent,
      ),
      body: Hoempae(),
      floatingActionButton: FloatingActionButton(
          child: Icon(Icons.add),
          onPressed: () {
            print("floatbtn.jk...");
          }),
    ),
  ));
}

class Hoempae extends StatefulWidget {
  const Hoempae({Key? key}) : super(key: key);

  @override
  _HoempaeState createState() => _HoempaeState();
}

class _HoempaeState extends State<Hoempae> {
  final usernamecontroller =TextEditingController();
  final passwordcontroller =TextEditingController();
  @override
  Widget build(BuildContext context) {
    //Icons字体图标
    //放大不会失真
    //可以设置颜色
    return Column(
      children: [
        SizedBox(
          height: 1,
        ),
        TextField(
          controller: usernamecontroller,
          decoration: InputDecoration(
            // labelText: "usesrname",
            icon: Icon(Icons.ac_unit),
            hintText: "请输入用户名",
            border: OutlineInputBorder(),
            filled: true,
            fillColor: Colors.white,
          ),
          onChanged: (valus) {
            //输入事件监听
            print(valus);
          },
          onSubmitted: (valus) {
            //提交
            print(valus);
          },
        ),
        SizedBox(
          height: 10,
        ),
        TextField(
          controller: passwordcontroller,
          decoration: InputDecoration(
              labelText: "password",
              icon: Icon(Icons.favorite),
              border: OutlineInputBorder(),
              hintText: "输入密码"),
        ),
        SizedBox(height: 12,),
        Container(
          width: 234,
          height: 40,
          child: FlatButton(
              color: Colors.green,
              onPressed: () {
                final username  =usernamecontroller.text;
                final password = passwordcontroller.text;
                print(username+password);
              },
              child: Text("提交")),
        ),
      ],
    );
  }
}
